use crate::http::server::handler::candidate_path::CandidatePathHandler;
use crate::http::server::handler::candidate_path_segment_list::CandidatePathSegmentListHandler;
use crate::http::server::handler::endpoint_srv6_config::EndpointSrv6ConfigHandler;
use crate::http::server::handler::network_acl::NetworkAclHandler;
use crate::http::server::handler::network_acl_rule::NetworkAclRuleHandler;
use crate::http::server::handler::node::NodeHandler;
use crate::http::server::handler::segment_list::SegmentListHandler;
use crate::http::server::handler::te_policy_group::TePolicyGroupHandler;
use crate::http::server::handler::traffic_steering_rule::TrafficSteeringRuleHandler;
use crate::http::server::handler::{
    AuthHandler, endpoint::EndpointHandler, endpoint_peer::EndpointPeerHandler,
    endpoint_peer_wireguard_config::EndpointPeerWireguardConfigHandler,
    endpoint_wireguard_config::EndpointWireguardConfigHandler,
};
use crate::{controller, mq};
use std::sync::Arc;

pub struct HandlerSet {
    pub auth: Arc<AuthHandler>,
    pub node: Arc<NodeHandler>,
    pub endpoint: Arc<EndpointHandler>,
    pub endpoint_srv6_config: Arc<EndpointSrv6ConfigHandler>,
    pub endpoint_wireguard_config: Arc<EndpointWireguardConfigHandler>,
    pub endpoint_peer: Arc<EndpointPeerHandler>,
    pub endpoint_peer_wireguard_config: Arc<EndpointPeerWireguardConfigHandler>,
    pub te_policy_group: Arc<TePolicyGroupHandler>,
    pub candidate_path: Arc<CandidatePathHandler>,
    pub candidate_path_segment_list: Arc<CandidatePathSegmentListHandler>,
    pub segment_list: Arc<SegmentListHandler>,
    pub network_acl: Arc<NetworkAclHandler>,
    pub network_acl_rule: Arc<NetworkAclRuleHandler>,
    pub traffic_steering_rule: Arc<TrafficSteeringRuleHandler>,
}

impl HandlerSet {
    pub fn new(
        controller_set: Arc<controller::controller_set::ControllerSet>,
        mq_client_factory: Arc<mq::client::Factory>,
    ) -> Self {
        Self {
            auth: Arc::new(AuthHandler::new(controller_set.clone())),
            node: Arc::new(NodeHandler::new(mq_client_factory)),
            endpoint: Arc::new(EndpointHandler::new(controller_set.clone())),
            endpoint_srv6_config: Arc::new(EndpointSrv6ConfigHandler::new(controller_set.clone())),
            endpoint_wireguard_config: Arc::new(EndpointWireguardConfigHandler::new(
                controller_set.clone(),
            )),
            endpoint_peer: Arc::new(EndpointPeerHandler::new(controller_set.clone())),
            endpoint_peer_wireguard_config: Arc::new(EndpointPeerWireguardConfigHandler::new(
                controller_set.clone(),
            )),
            te_policy_group: Arc::new(TePolicyGroupHandler::new(controller_set.clone())),
            candidate_path: Arc::new(CandidatePathHandler::new(controller_set.clone())),
            candidate_path_segment_list: Arc::new(CandidatePathSegmentListHandler::new(
                controller_set.clone(),
            )),
            segment_list: Arc::new(SegmentListHandler::new(controller_set.clone())),
            network_acl: Arc::new(NetworkAclHandler::new(controller_set.clone())),
            network_acl_rule: Arc::new(NetworkAclRuleHandler::new(controller_set.clone())),
            traffic_steering_rule: Arc::new(TrafficSteeringRuleHandler::new(
                controller_set.clone(),
            )),
        }
    }
}
